package com.chuangyang.fixboxmaster.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.android.volley.Request;
import com.chuangyang.fixboxlib.widgets.ProgressFragment;
import com.chuangyang.fixboxmaster.R;
import com.chuangyang.fixboxmaster.service.RequestManager;
import com.chuangyang.fixboxmaster.ui.fragment.home.HomeFragment;
import com.chuangyang.fixboxmaster.ui.fragment.repair.RepairListFragment;

import static com.chuangyang.fixboxlib.utils.LogUtils.makeLogTag;


/**
 * Created by Van on 2015/2/5.
 */
public class BaseFragment extends ProgressFragment {
    private static final String TAG = makeLogTag(BaseFragment.class);
    private String title;
    private int iconId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_progress_layout, container, false);
        ImageView mEmptyView = (ImageView) root.findViewById(R.id.empty_view);
        TextView mNoData = (TextView) root.findViewById(R.id.no_data);
        if (this instanceof RepairListFragment) {
            mEmptyView.setBackgroundResource(R.drawable.ic_empty_view);
            mNoData.setText("暂无可接订单");
        }else if(this instanceof HomeFragment)
        {
            mEmptyView.setBackgroundResource(R.drawable.ic_empty_view);
            mNoData.setText("暂无订单");
        }

        return root;
    }


    protected void setEmptyView() {
        setContentEmpty(true);
        setContentShown(true);
    }

    protected void showResult() {
        setContentEmpty(false);
        setContentShown(true);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        setOnDestroy();
    }


    public String getTabTitle() {
        return title;
    }

    public void setTabTitle(String title) {
        this.title = title;
    }

    public int getTabIconId() {
        return iconId;
    }

    public void setTabIconId(int iconId) {
        this.iconId = iconId;
    }


    protected void addRequest(Request request) {
        RequestManager.addRequest(request, this);
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    public interface OnPullRefreshListener {
        void onPullRefresh();
    }

    public ListView getListView() {
        return null;
    }

}
